Telling Stories with Data

Spring 2026

This is a data science class…

What does this mean?

R vs. RStudio

R

R is a programming language.

  • Your computer operates on a series of 0/1s
  • R is the translator between you and the computer
  • Object oriented programming language

Rstudio

Rstudio is an integrated developmental environment (IDE)

  • “Automatic transmission” of the R programming language
  • Lightweight interface
  • Aesthetically pleasing and user friendly

Why R?

Packages in R

R is a functional programming language.


A function is a self-contained block of code that accomplishes a specific task


Functions are bundled within packages

Demo!

Some Technical Notes

R is case sensitive…


x is not the same as X.

my_variable is not the same as My_Variable.

sum() is not the same as SUM().


but R is communicative

anthro <- "is_awesome"
anthr
Error: object 'anthr' not found


Always check spelling first (and syntax)…

Object Names

Everything is stored in R as an Object

anthro <- "rocks"

Object names should:

  1. Start with a letter

  2. Be descriptive, concise, and meaningful


General naming conventions:

  • Snake case: obj_name

  • Camel case: ObjName

  • Periods: obj.name

The Assignment Operator


The assignment operator [<-] is used to assign values to objects. The following lines of code are read as “___ gets the value of ___”.


x <- 42
y <- 5

x + y
[1] 47
Demonstration of pipe table syntax
Windows Mac
Shortcut Alt + - Option + -

PSA: Anticlimatic

After assigning a value to an object, R does not automatically show it in your console. It does populate in the [Environment Pane]. Double check your object exists by typing the name of the object or checking the local environment. Note, it must exist locally to be used in other observations.

fabulous <- "pot sherds"
fabulous
[1] "pot sherds"

Common Problems


Quotation marks and parentheses must come in pairs!


R will “tell you” with a [+] sign…

x <- "hello
+
+
+

Solution: Press [Esc] to cancel that line of code and start again.

Getting Help

  • The ? followed by some function or object name searches specific documentation. This is the same as the function help()
?sum
help(sum)
  • The ?? followed by some word or phrase is a broader search function and searches all documentation in memory. This is shorthand for help.search()
??"linear model"
help.search("linear model")

Tidyverse Style Guide

Canyoureadthissentence?

  • After function names, do not leave a space

  • Before and after operator (+, -, <-, *, /), leave a space

  • Put a space after a comma, not before

  • Use consistent style –> whatever that may be…


  • https://style.tidyverse.org/

Begin a New Atomic Habit

  1. Open RStudio and type “Good morning, R” into the console. That’s it. Seriously.

  2. Write code for 5 minutes

  3. Use one new function. Reading the help page counts.

  4. Make a single commit on git.

  5. Be mundane.